package javaMetaModel;

import javaMetaModel.visitor.IMetaModelVisitor;

public class MetaPackage {

	protected String mName;

	protected MetaPackage mParent;

	public MetaPackage(String aPackageName) {
		this.mName = aPackageName;
	}

	public MetaPackage() {
		this("");
	}

	public String getName() {
		return mName;
	}

	public void setName(String mName) {
		this.mName = mName;
	}

	public boolean isEmpty() {
		return this.getCompleteName().isEmpty();
	}

	public void accept(IMetaModelVisitor aVisitor) {
		aVisitor.visitPackage(this);
	}

	public MetaPackage getParent() {
		return this.mParent;
	}

	public void setParentPackage(MetaPackage aPackage) {
		this.mParent = aPackage;
	}

	public String getCompleteName() {
		String completeName = this.getName();

		// Si un package parent existe
		if (this.getParent() != null) {

			// Concatenation avec le nom complet du parent.
			completeName = this.getParent().getCompleteName() + "."
					+ this.getName();
		}

		return completeName;
	}

	@Override
	public String toString() {
		return this.getCompleteName();
	}

}
